﻿using System;
using System.Collections;
using System.Xml;
using System.Xml.Schema;
using InfoJetSoft.Service.Util;

namespace InfoJetSoft.Service.Entity
{
	public class Manifest
	{

		public ImageURI ImageUri
		{
			get
			{
				return imageUri;
			}
			
			set
			{
				this.imageUri = value;
			}
			
		}
		
		public string MD5
		{
			get
			{
				return md5;
			}
			
			set
			{
				this.md5 = value;
			}
			
		}

		public string PublishUrl
		{
			get
			{
				return publishUrl;
			}
			
			set
			{
				this.publishUrl = value;
			}
			
		}
		
		public ArrayList DomEventHandlerList
		{
			get
			{
				return domEventHandlerList;
			}
			
			set
			{
				this.domEventHandlerList = value;
			}
			
		}

		public ArrayList HandlerObjectList
		{
			get
			{
				return this.handlerObjectList;
			}
			
			set
			{
				this.handlerObjectList = value;
			}
			
		}
		
		public string SolutionFormatVersion
		{
			get
			{
				return solutionFormatVersion;
			}
			
			set
			{
				this.solutionFormatVersion = value;
			}
			
		}
		
		public Upgrade Upgrade
		{
			get
			{
				return upgrade;
			}
			
			set
			{
				this.upgrade = value;
			}
			
		}
		
		public VersionCode SolutionVersion
		{
			get
			{
				return solutionVersion;
			}
			
			set
			{
				this.solutionVersion = value;
			}
			
		}

		public VersionCode ProductVersion
		{
			get
			{
				return this.productVersion;
			}
			
			set
			{
				this.productVersion = value;
			}
			
		}
		
		public ArrayList ErrorConditionList
		{
			get
			{
				return errorConditionList;
			}
			
			set
			{
				this.errorConditionList = value;
			}
			
		}

        public ArrayList ErrorBlankList
        {
            get
            {
                return errorBlankList;
            }

            set
            {
                this.errorBlankList = value;
            }

        }

		public XmlSchemaCollection SchemaCollection
		{
			get
			{
				return schemaCollection;
			}
			
			set
			{
				this.schemaCollection = value;
			}
			
		}

		public XmlSchemaSet SchemaSet
		{
			get
			{
				return schemaSet;
			}
			
			set
			{
				this.schemaSet = value;
			}
			
		}
		
		public ArrayList SchemaDefList
		{
			get
			{
				return schemaDefList;
			}
			
			set
			{
				this.schemaDefList = value;
			}
			
		}
		
		public string XsfPrefix
		{
			get
			{
				return xsfPrefix;
			}
			
			set
			{
				this.xsfPrefix = value;
			}
			
		}
		
		public NamespaceResolver NsResolver
		{
			get
			{
				return nsResolver;
			}
			
			set
			{
				this.nsResolver = value;
			}
			
		}
		
		public SchemaDef RootSchemaDef
		{
			get
			{
				return rootSchemaDef;
			}
			
			set
			{
				this.rootSchemaDef = value;
			}
			
		}
		
		public XSNConfig XSNConfig
		{
			get
			{
				return xsnConfig;
			}
			
			set
			{
				this.xsnConfig = value;
			}
			
		}
		
		public ArrayList XmlToEditList
		{
			get
			{
				return xmlToEditList;
			}
			
			set
			{
				this.xmlToEditList = value;
			}
			
		}
		
		public CABFile CabFile
		{
			get
			{
				return cabFile;
			}
			
			set
			{
				this.cabFile = value;
			}
			
		}
		
		public ArrayList CabFileList
		{
			get
			{
				return cabFileList;
			}
			
			set
			{
				this.cabFileList = value;
			}
			
		}
		
		public Template Template
		{
			get
			{
				return template;
			}
			
			set
			{
				this.template = value;
			}
			
		}
		
		public View DefaultView
		{
			get
			{
				return defaultView;
			}
			
			set
			{
				this.defaultView = value;
			}
			
		}
		
		public ArrayList ViewList
		{
			get
			{
				return viewList;
			}
			
			set
			{
				this.viewList = value;
			}
			
		}
		
		public XmlDocument Doc
		{
			get
			{
				return doc;
			}
			
			set
			{
				this.doc = value;
			}
			
		}

		public System.Collections.ArrayList DataObjectList {
			get {
				return this.dataObjectList;
			}
			
			set {
				this.dataObjectList = value;
			}
			
		}

		public System.Collections.ArrayList DataAdapterList 
		{
			get 
			{
				return this.dataAdapterList;
			}
			
			set 
			{
				this.dataAdapterList = value;
			}
			
		}

		public System.Collections.ArrayList CalculatedFieldList {
			get {
				return this.calculatedFieldList;
			}
			
			set {
				this.calculatedFieldList = value;
			}
			
		}

		public XmlDocument QueryXsltTempDoc {
			get {
				return this.queryXsltTempDoc;
			}
			
			set {
				this.queryXsltTempDoc = value;
			}
			
		}

		public Query Query {
			get {
				return this.query;
			}
			
			set {
				this.query = value;
			}
			
		}

		public Submit Submit {
			get {
				return this.submit;
			}
			
			set {
				this.submit = value;
			}
			
		}

		public System.Collections.ArrayList SchemaLinkList {
			get {
				return this.schemaLinkList;
			}
			
			set {
				this.schemaLinkList = value;
			}
			
		}

		public OnLoad OnLoad {
			get {
				return this.onLoad;
			}
			
			set {
				this.onLoad = value;
			}
			
		}

		public Roles Roles {
			get {
				return roles;
			}
			
			set {
				this.roles = value;
			}
			
		}

		public ArrayList ConditionFormatTestList{
			get 
			{
				return conditionFormatTestList;
			}
			
			set 
			{
				this.conditionFormatTestList = value;
			}

		}

        // Erucy: Remove in 2007
        //public string Folder
        //{
        //    get 
        //    {
        //        return folder;
        //    }

        //    set 
        //    {
        //        this.folder = value;
        //    }

        //}

		public ManagedAssembly ManagedAssembly
		{
			get 
			{
				return managedAssembly;
			}
			
			set 
			{
				this.managedAssembly = value;
			}

		}

		public ScriptSource ScriptSource
		{
			get 
			{
				return scriptSource;
			}
			
			set 
			{
				this.scriptSource = value;
			}

		}

		public ImportParameters ImportParameters
		{
			get
			{
				return this.importParameters;
			}
			
			set
			{
				this.importParameters = value;
			}
			
		}

		public FormConfiguration FormConfiguration
		{
			get
			{
				return this.formConfiguration;
			}
			
			set
			{
				this.formConfiguration = value;
			}
			
		}

		public XmlDocument DataFlowConfigurationDoc
		{
			get
			{
				return this.dataFlowConfigurationDoc;
			}
			
			set
			{
				this.dataFlowConfigurationDoc = value;
			}
			
		}

		public object DataFlowConfiguration
		{
			get
			{
				return this.dataFlowConfiguration;
			}
			
			set
			{
				this.dataFlowConfiguration = value;
			}
			
		}

		public bool IsADOSubmit
		{
			get
			{
				return this.isADOSubmit;
			}
			
			set
			{
				this.isADOSubmit = value;
			}
			
		}

		public string ResourceFolderPath
		{
			get
			{
				return this.resourceFolderPath;
			}
			
			set
			{
				this.resourceFolderPath = value;
			}
			
		}

		public string ResourceFolderName
		{
			get
			{
				return this.resourceFolderName;
			}
			
			set
			{
				this.resourceFolderName = value;
			}
			
		}

		public ArrayList TaskPaneList
		{
			get
			{
				return this.taskPaneList;
			}
			
			set
			{
				this.taskPaneList = value;
			}
			
		}

		public Hashtable NillableSchemaTypeTable
		{
			get
			{
				return this.nillableSchemaTypeTable;
			}
			
			set
			{
				this.nillableSchemaTypeTable = value;
			}
			
		}

		public Hashtable NonNillableBASE64SchemaTypeTable
		{
			get
			{
				return this.nonNillableBASE64SchemaTypeTable;
			}
			
			set
			{
				this.nonNillableBASE64SchemaTypeTable = value;
			}
			
		}

		public ArrayList XhtmlElementNameList
		{
			get
			{
				return this.xhtmlElementNameList;
			}
			set
			{
				this.xhtmlElementNameList = value;
			}
		}

		public string NonProofingNodeNameArrays
		{
			get
			{
				return this.nonProofingNodeNameArrays;
			}
			set
			{
				this.nonProofingNodeNameArrays = value;
			}
		}

        public Hashtable PNGInfoTable
        {
            get
            {
                return this.pngInfoTable;
            }
            set
            {
                this.pngInfoTable = value;
            }
        }

        public Hashtable EXIInfoTable
        {
            get
            {
                return this.exiInfoTable;
            }
            set
            {
                this.exiInfoTable = value;
            }
        }

        public ArrayList HtmlOnClickList
        {
            get 
            {
                return this.htmlOnClickList;
            }
            set
            {
                this.htmlOnClickList = value;
            }
        }

        //CID 0724 //2010.12.19 //Begin
        public bool FormFieldsCacheEnabled
        {
            get
            {
                if (this.formFieldsCacheValue == 0)
                {
                    return ConfigUtil.EnableFormFieldsCache();
                }
                else
                {
                    if (this.formFieldsCacheValue == 1)
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
        }
        //CID 0724 //2010.12.19 //End

        //CID 0724 //2010.12.19 //Begin
        public void SetFormFieldsCacheValue( int value )
        {
            this.formFieldsCacheValue = value;
        }
        //CID 0724 //2010.12.19 //End

        //CID 0703 //2010.12.20 //Begin
        public string RelativeUrlBase
        {
            get
            {
                return this.relativeUrlBase;
            }
            set
            {
                this.relativeUrlBase = value;
            }
        }
        //CID 0703 //2010.12.20 //End

        public string Xsf2Prefix
        {
            get
            {
                return this.xsf2Prefix;
            }
            set
            {
                this.xsf2Prefix = value;
            }
        }

        public string Xsf3Prefix
        {
            get
            {
                return this.xsf3Prefix;
            }
            set
            {
                this.xsf3Prefix = value;
            }
        }

        public bool EnableBindingTest
        {
            get
            {
                //CID 0825 //2011.03.06 //Begin
                //Check configuratin key.
                //CID 0825 //2011.03.06 //End
                return this.enableBindingTest;
            }
            set
            {
                this.enableBindingTest = value;
            }
        }

        public ArrayList DrondownListInfos
        {
            get
            {
                return this.dropdownListInfos;
            }
            set
            {
                this.dropdownListInfos = value;
            }
        }

        public ArrayList SignedDataBlockList
        {
            get
            {
                return this.signedDataBlockList;
            }
            set
            {
                this.signedDataBlockList = value;
            }
        }

        public string SampleDataFile
        {
            get
            {
                return this.sampleDataFile;
            }
            set
            {
                this.sampleDataFile = value;
            }
        }

        public string Digest
        {
            get
            {
                return this.digest;
            }
            set
            {
                this.digest = value;
            }
        }

        public int Size
        {
            get
            {
                return this.size;
            }
            set
            {
                this.size = value;
            }
        }

        public string Id
        {
            get
            {
                return this.id;
            }
            set
            {
                this.id = value;
            }
        }

		public InfoJetContext JetContext
		{
			get
			{
				return this.jetContext;
			}
			
			set
			{
				this.jetContext = value;
			}
			
		}

		private InfoJetContext jetContext = null;

        //CID 0618 //2010.06.28 //Begin
        private string id = Guid.NewGuid().ToString();
        //CID 0618 //2010.06.28 //End

		private XSNConfig xsnConfig = null;
		private ArrayList cabFileList = null;
		private XmlDocument doc = null;
		private ArrayList viewList = null;
		private View defaultView = null;
		private Template template = null;
		private SchemaDef rootSchemaDef = null;
		private ArrayList schemaDefList = null;
		private CABFile cabFile = null;
		private ArrayList xmlToEditList = null;
		private string xsfPrefix = null;
		private NamespaceResolver nsResolver = null;
		private XmlSchemaCollection schemaCollection = null;
		//CID 0422 //2009.10.14 //Begin
        //CID 0611 //2010.06.04 //Begin
        private XmlSchemaSet schemaSet = null;
        //CID 0611 //2010.06.04 //End
		//CID 0422 //2009.10.14 //End
		private ArrayList errorConditionList = null;
        //CID 0858 //2011.03.29 //Begin
        private ArrayList errorBlankList = null;
        //CID 0858 //2011.03.29 //End
		private string solutionFormatVersion = null;
		private Upgrade upgrade = null;
		private ArrayList domEventHandlerList = null;
		private ArrayList handlerObjectList = null;
		private string md5 = null;
        //CID 0749 //2011.09.19 //Begin
        private string digest = null;
        private int size = 0;
        //CID 0749 //2011.09.19 //End
		private string publishUrl = null;
		private ImageURI imageUri = null;
		private ArrayList dataObjectList = null;
		private ArrayList dataAdapterList = null;
		private ArrayList calculatedFieldList = null;
		private XmlDocument queryXsltTempDoc = null;
		private Query query = null;
		private Submit submit = null;
		private VersionCode solutionVersion = null;
		private VersionCode productVersion = null;
		private ArrayList schemaLinkList = null;
		private OnLoad onLoad = null;
		private Roles roles = null;
		private ArrayList conditionFormatTestList = null;
		private string folder = null;
		private ManagedAssembly managedAssembly = null;
		private ScriptSource scriptSource = null;
		private ImportParameters importParameters = null;
		private FormConfiguration formConfiguration = null;
		private bool isADOSubmit = false;
		private string resourceFolderPath = null;
		private string resourceFolderName = null;
		private ArrayList taskPaneList = null;
		//用于存储在XSNViewFormatControlWorker中分析到的nillable为true的Date类型的所有SchemaType.
		//在FormRemoveNilTrueWorker中当数据为空时,设置xsi:nil="true".
		//key为bindingNodeName.
		private Hashtable nillableSchemaTypeTable = null;
		//用于存储非Nillable的base64binary的SchemaType,因为非Nillable的文件附件要进行特殊处理.2.xsn
		private Hashtable nonNillableBASE64SchemaTypeTable = null;

		//InfoJet Service只提供DataFlowConfigurationDoc,又DataFlow在需要时Parse,并设置dataFlowConfiguration.
		private XmlDocument dataFlowConfigurationDoc = null;
		//dataFlowConfiguration的类型在InfoJetSoft.DataFlow中定义.
		private object dataFlowConfiguration = null;

		//CID 0167 //2008.12.15 //Begin
		private ArrayList importParameterList = null;
		//CID 0167 //2008.12.15 //End

		//CID 0235 //2009.03.03 //Begin
		private ArrayList hyperlinkList = null;
		//CID 0235 //2009.03.03 //End

        //CID 0619 //2010.06.24 //Begin
        private ArrayList htmlScriptList = null;
        //CID 0619 //2010.06.24 //End

        //CID 0644 //2010.08.26 //Begin
        private ArrayList refreshDefaultValueNodeNameList = null;
        //CID 0644 //2010.08.26 //End

        //CID 0626 //2010.07.12 //Begin
        private ArrayList customDSNames = null;
        //CID 0626 //2010.07.12 //End

        //CID 0629 //2010.07.30 //Begin
        private ArrayList htmlOnChangeList = null;
        //CID 0629 //2010.07.30 //End

		//CID 0331 //2009.07.27 //Begin
		private ArrayList xhtmlElementNameList = null;
		//CID 0331 //2009.07.27 //End

		//CID 0526 //2010.03.30 //Begin
		private string nonProofingNodeNameArrays = null;
		//CID 0526 //2010.03.30 //End

        //CID 0701 //2010.11.08 //Begin
        private Hashtable pngInfoTable = null; 
        //CID 0701 //2010.11.08 //End

        //CID 0657 //2010.12.08 //Begin
        private Hashtable exiInfoTable = null;
        //CID 0657 //2010.12.08 //End

        //CID 0735 //2010.12.19 //Begin
        private ArrayList htmlOnClickList = null;
        //CID 0735 //2010.12.19 //End

        //CID 0724 //2010.12.19 //Begin
        private int formFieldsCacheValue = 0;
        //CID 0724 //2010.12.19 //End

        //CID 0703 //2010.12.20 //Begin
        private string xsf2Prefix = null;
        private string xsf3Prefix = null;
        private string relativeUrlBase = null;
        //CID 0703 //2010.12.20 //End

        //CID 0825 //2011.03.06 //Begin
        private bool enableBindingTest = false;
        //CID 0825 //2011.03.06 //End

        //CID 0800 //2011.03.14 //Begin
        private ArrayList dropdownListInfos = null;
        //CID 0800 //2011.03.14 //End

        //CID 0951 //2011.06.17 //Begin
        private string sampleDataFile = null;
        //CID 0951 //2011.06.17 //End

        //CID 0749 //2011.08.30 //Begin
        private ArrayList signedDataBlockList = null;
        //CID 0749 //2011.08.30 //End

		public ArrayList ImportParameterList
		{
			get
			{
				return this.importParameterList;
			}
			set
			{
				this.importParameterList = value;
			}
		}

		public ArrayList HyperlinkList
		{
			get
			{
				return this.hyperlinkList;
			}
			set
			{
				this.hyperlinkList = value;
			}
		}

        public ArrayList HtmlScriptList
        {
            get
            {
                return this.htmlScriptList;
            }
            set
            {
                this.htmlScriptList = value;
            }
        }

        public ArrayList HtmlOnChangeList
        {
            get
            {
                return this.htmlOnChangeList;
            }
            set
            {
                this.htmlOnChangeList = value;
            }
        }

        public ArrayList RefreshDefalutValueNodeNameList
        {
            get
            {
                return this.refreshDefaultValueNodeNameList;
            }
            set
            {
                this.refreshDefaultValueNodeNameList = value;
            }
        }

        public ArrayList CustomDSNames
        {
            get
            {
                return this.customDSNames;
            }
            set
            {
                this.customDSNames = value;
            }
        }
		
		public Manifest(XSNConfig xsnConfig)
		{
			this.xsnConfig = xsnConfig;
			this.imageUri = new ImageURI(this.xsnConfig.WebContext);
		}
		
		public View getView(string viewId)
		{
			if (viewId == null)
			{
				return this.defaultView;
			}
			viewId = viewId.Trim();
			foreach (View view in this.viewList)
			{
				if (view.Id.Equals(viewId))
				{
					return view;
				}
			}
			return this.defaultView;
		}

		public string getViewId(string viewName)
		{
			if( viewName == null )
			{
				return this.defaultView.Id;
			}
			foreach (View view in this.viewList)
			{
				if (view.Name.Equals(viewName))
				{
					return view.Id;
				}
			}
			return this.defaultView.Id;
		}

		public string getPrintViewId(string viewId)
		{
			if( viewId == null )
			{
				return this.defaultView.Id;
			}
			foreach (View view in this.viewList)
			{
				if (view.Id.Equals(viewId))
				{
					if( view.PrintView != null )
					{
						foreach(View view2 in this.viewList)
						{
							if( view2.Name.Equals( view.PrintView ) )
							{
								return view2.Id;
							}
						}
					}
				}
			}
			return this.defaultView.Id;
		}

		public View getViewByName(string viewName)
		{
			foreach (View view in this.viewList)
			{
				if (view.Name.Equals(viewName))
				{
					return view;
				}
			}
			return null;
		}

        //CID 1503 //2012.12.19 //Begin
        public XmlNodeList ViewExtension2List
        {
            get;
            set;
        }
        //CID 1503 //2012.12.19 //End

        //CID 1503 //2012.12.19 //Begin
        public XmlNodeList ViewExtension3List
        {
            get;
            set;
        }
        //CID 1503 //2012.12.19 //End
	}
}